package com.aipolice.pojo;

import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "user_", schema = "aipolice")
@Where(clause = "del = 0")
public class User {
    private int id;
    private String username;
    private String password;
    private String realname;
    private String tel;
    private String dfAddress;
    private String emgContactName;
    private String emgContactNum;
    private Integer del;
    private Timestamp createTime;
    private Timestamp updateTime;

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", realname='" + realname + '\'' +
                ", tel='" + tel + '\'' +
                ", dfAddress='" + dfAddress + '\'' +
                ", emgContactName='" + emgContactName + '\'' +
                ", emgContactNum='" + emgContactNum + '\'' +
                ", del=" + del +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }

    @Id
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "username")
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Basic
    @Column(name = "password")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name = "realname")
    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    @Basic
    @Column(name = "tel")
    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    @Basic
    @Column(name = "df_address")
    public String getDfAddress() {
        return dfAddress;
    }

    public void setDfAddress(String dfAddress) {
        this.dfAddress = dfAddress;
    }

    @Basic
    @Column(name = "emg_contact_name")
    public String getEmgContactName() {
        return emgContactName;
    }

    public void setEmgContactName(String emgContactName) {
        this.emgContactName = emgContactName;
    }

    @Basic
    @Column(name = "emg_contact_num")
    public String getEmgContactNum() {
        return emgContactNum;
    }

    public void setEmgContactNum(String emgContactNum) {
        this.emgContactNum = emgContactNum;
    }

    @Basic
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }

    public void setDel(Integer del) {
        this.del = del;
    }

    @Basic
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time")
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return id == user.id &&
                Objects.equals(username, user.username) &&
                Objects.equals(password, user.password) &&
                Objects.equals(realname, user.realname) &&
                Objects.equals(tel, user.tel) &&
                Objects.equals(dfAddress, user.dfAddress) &&
                Objects.equals(emgContactName, user.emgContactName) &&
                Objects.equals(emgContactNum, user.emgContactNum) &&
                Objects.equals(del, user.del) &&
                Objects.equals(createTime, user.createTime) &&
                Objects.equals(updateTime, user.updateTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, username, password, realname, tel, dfAddress, emgContactName, emgContactNum, del, createTime, updateTime);
    }
}
